package com.igeek.web;

import com.igeek.domain.Category;
import com.igeek.service.CategoryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @author jerry
 */
@RestController
@Slf4j
public class HomeController {
    @Autowired
    private CategoryService categoryService;
    //forehome
    @GetMapping("/forehome")
    public List<Category> getHomeData(HttpServletRequest request){
        List<Category> categories = categoryService.list();
        categoryService.filleProduct(categories);
        categoryService.fillProductsByRow(categories);
        log.info("categories:"+categories);
        return categories;
    }
}
